﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Backend/Backend.Master" AutoEventWireup="true" CodeBehind="MenuList.aspx.cs" Inherits="Phoenix.Backend.MenuList" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<!-- Begin List -->
	<div id="list" class="onecolumn" runat="server">
		<div class="header">
			<span>List Danh Mục</span>
			<div class="switch" style="margin:7px 15px;">
				<table cellpadding="0" cellspacing="0">
				<tbody>
					<tr>
						<td>
                            <a href="MenuList.aspx?Action=Create" class="button">Thêm mới</a>
						</td>
					</tr>
				</tbody>
				</table>
			</div>
		</div>
		<br class="clear"/>
		<div class="content">  
            <asp:Label ID="lblWarning" runat="server"></asp:Label>      
            <table width="100%">
                <tr>
                    <td>
                        <div id="tablewrapper">
                            <div id="tableheader">
                                <div class="search">
                                    <select id="columns" onchange="sorter.search('query')">
                                    </select>
                                    <input type="text" id="query" onkeyup="sorter.search('query')" style="width:170px;" />
                                </div>
                                <div class="details">
                                    <div class="ddl">
                                        <label>Loại danh mục:</label> <asp:DropDownList ID="ddlMenuBack_FrontEnd" runat="server" AutoPostBack="True" 
                                            onselectedindexchanged="ddlMenuBack_FrontEnd_SelectedIndexChanged"></asp:DropDownList>
                                    </div>
                                    <div>
                                        <asp:Label ID="Label20" runat="server" Text='Kết quả' />
                                        <span id="startrecord"></span>-<span id="endrecord"></span>
                                        <asp:Label ID="Label21" runat="server" Text='của' />
                                        <span id="totalrecords"></span>
                                    </div>
                                    <div>
                                        <a href="javascript:sorter.reset()">
                                            <asp:Label ID="Label23" runat="server" Text='Thiết lập lại' /></a></div>
                                </div>
                            </div>
                            <table cellpadding="0" cellspacing="0" border="0" id="table" class="tinytable">
                                <thead>
                                    <tr>
                                        <th><h3>Mã DM</h3></th>
                                        <th><h3>Thuộc mã DM</h3></th>
                                        <th><h3>Tên danh mục</h3></th>
                                        <th><h3>Đường dẫn</h3></th>
                                        <th><h3>Loại DM</h3></th>
                                        <th><h3>Thứ tự</h3></th>
                                        <th class="nosort"><h3>Ẩn/Hiện</h3></th>
                                        <th class="nosort"><h3>Sửa</h3></th>
                                        <th class="nosort"><h3>Xóa</h3></th>
                                        
                                    </tr>
                                </thead>
                                <tbody>
                                    <%
                                        /* write code get datatable show into for loop */
                                        //System.Data.DataTable dt = Phoenix.AppCode.Bussiness.MenuListService.MenuListListByBeFe(Convert.ToInt32(Request.Cookies["ddlMenuBack_FrontEnd"].Value.Trim()), Request.Cookies["Lang_Backend"].Value);
                                        for (int i = 0; i < dt.Rows.Count; i++)
                                        {
                                    %>
                                    <tr>
                                        <td style="width:55px; text-align:center;"><%=dt.Rows[i]["ID_MenuList"].ToString()%></td>
                                        <td style="width:100px; text-align:center;"><%=dt.Rows[i]["ID_MenuList_Parent"].ToString()%></td>
                                        <td><%=dt.Rows[i]["MenuName"].ToString()%></td>
                                        <td><%=dt.Rows[i]["URL"].ToString()%></td>
                                        <td style="width:75px; text-align:center;"><% if (dt.Rows[i]["MenuBack_FrontEnd"].ToString().Equals("1")) {%>Quản lý<%} else {%>Người dùng<%}%></td>
                                        <td style="width:60px; text-align:center;"><%=dt.Rows[i]["Location"].ToString()%></td>
                                        <td style="width:60px;text-align:center;" valign="middle"><%if (dt.Rows[i]["Visible"].ToString().Equals("True")){ %>
                                            <a href="MenuList.aspx?Action=OnOff&ID=<%=dt.Rows[i]["ID_MenuList"].ToString() %>"><img alt="" src="http://localhost:1109/Content/Backend/js/table/images/activation.png" /></a><% }else { %>
                                            <a href="MenuList.aspx?Action=OnOff&ID=<%=dt.Rows[i]["ID_MenuList"].ToString() %>"><img alt="" src="http://localhost:1109/Content/Backend/js/table/images/inactivation.png" /></a><% } %></td>
                                        <td style="width:50px;text-align:center">
                                            <a href="MenuList.aspx?Action=Edit&ID=<%=dt.Rows[i]["ID_MenuList"].ToString() %>"><img alt="" src="http://localhost:1109/Content/Backend/js/table/images/grid_edit.png" /></a></td>
                                        <td style="width:50px;text-align:center">
                                            <a href="javascript: if (confirm('Bạn muốn tiếp tục xóa bản tin này không?')) { window.location.href='MenuList.aspx?Action=Delete&ID=<%=dt.Rows[i]["ID_MenuList"].ToString() %>' } else { void('') }; "> 
                                            <img alt="" src="http://localhost:1109/Content/Backend/js/table/images/delete.png" /></a></td>
                                    </tr>
                                    <% } %>
                                </tbody>
                            </table>
                            
                            <div id="tablefooter">
                                <div id="tablenav">
                                    <div>
                                        <img alt="" src="http://localhost:1109/Content/Backend/js/table/images/first.gif" />
                                        <img src="http://localhost:1109/Content/Backend/js/table/images/first.gif" width="16" height="16" alt="First Page"
                                            onclick="sorter.move(-1,true)" />
                                        <img src="http://localhost:1109/Content/Backend/js/table/images/previous.gif" width="16" height="16" alt="First Page"
                                            onclick="sorter.move(-1)" />
                                        <img src="http://localhost:1109/Content/Backend/js/table/images/next.gif" width="16" height="16" alt="First Page" onclick="sorter.move(1)" />
                                        <img src="http://localhost:1109/Content/Backend/js/table/images/last.gif" width="16" height="16" alt="Last Page" onclick="sorter.move(1,true)" />
                                    </div>
                                    <div>
                                        <select id="pagedropdown">
                                        </select>
                                    </div>
                                    <div>
                                        <a href="javascript:sorter.showall()">
                                            <asp:Label ID="Label25" runat="server" Text='Xem tất cả' /></a>
                                    </div>
                                </div>
                                <div id="tablelocation">
                                    <div>
                                        <select onchange="sorter.size(this.value)">
                                            <option value="5">5</option>
                                            <option value="10" selected="selected">10</option>
                                            <option value="20">20</option>
                                            <option value="50">50</option>
                                            <option value="100">100</option>
                                        </select>
                                        <span>
                                            <asp:Label ID="Label24" runat="server" Text='Kết quả mỗi trang' /></span>
                                    </div>
                                    <div class="page">
                                        <asp:Label ID="Label55" runat="server" Text='Trang' />
                                        <span id="currentpage"></span>
                                        <asp:Label ID="Label26" runat="server" Text='của' />
                                        <span id="totalpages"></span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <script type="text/javascript" src="http://localhost:1109/Content/Backend/js/table/3.js"></script>
                        <script type="text/javascript">
                            var sorter = new TINY.table.sorter('sorter', 'table', {
                                headclass: 'head',
                                ascclass: 'asc',
                                descclass: 'desc',
                                evenclass: 'evenrow',
                                oddclass: 'oddrow',
                                evenselclass: 'evenselected',
                                oddselclass: 'oddselected',
                                paginate: true,
                                size: 10,
                                colddid: 'columns',
                                currentid: 'currentpage',
                                totalid: 'totalpages',
                                startingrecid: 'startrecord',
                                endingrecid: 'endrecord',
                                totalrecid: 'totalrecords',
                                hoverid: 'selectedrow',
                                pageddid: 'pagedropdown',
                                navid: 'tablenav',
                                sortcolumn: 0,
                                sortdir: -1,
                                /* sum:[8],
                                avg:[6,7,8,9],
                                columns:[{index:7, format:'%', decimals:1},{index:8, format:'$', decimals:0}], */
                                init: true
                            });
                        </script>
                    </td>
                </tr>
            </table>
		</div>
	</div>
<!-- End List -->
<!-- Begin Create -->
	<div id="add" class="onecolumn" runat="server" visible="false">
		<div class="header">
			<span>Thêm Danh Mục</span>
			<div class="switch" style="margin:7px 15px;">
				<table cellpadding="0" cellspacing="0">
				<tbody>
					<tr>
						<td>
                            <a href="MenuList.aspx" class="button">Danh sách</a>
						</td>
					</tr>
				</tbody>
				</table>
			</div>
		</div>
		<br class="clear"/>
		<div class="content">
            <asp:Label ID="lblWarningA" runat="server"></asp:Label>
            <fieldset class="fieldset"><legend><label>Tên danh mục</label></legend>
			    <div class="left">
                    Tiếng Việt:<br />
                    <asp:TextBox ID="txtMenuNameA_vi" runat="server" style="width:300px"></asp:TextBox>
			    </div>
                <div class="left">
                    Tiếng Anh:<br />
                    <asp:TextBox ID="txtMenuNameA_en" runat="server" style="width:300px"></asp:TextBox>
                </div>
            </fieldset><br class="clear"/>
            <div style="padding-left:12px;">
                <div class="left"> 
                    <label>Loại danh mục:</label><br />
                    <asp:DropDownList ID="ddlMenuBack_FrontEndA" runat="server" style="width:311px" AutoPostBack="True" 
                        onselectedindexchanged="ddlMenuBack_FrontEndA_SelectedIndexChanged"></asp:DropDownList>
                </div>
                <div class="left"> 
                    <label>Thuộc danh mục:</label><br />
                    <asp:DropDownList ID="ddlMenuNameA" runat="server" style="width:311px"></asp:DropDownList>
                </div>
            </div><br class="clear"/><br />
            <div style="padding-left:12px;">
                <div class="left"> 
                    <label>Đường dẫn:</label><br />
                    <asp:TextBox ID="txtURLA" runat="server" style="width:300px"></asp:TextBox>
                </div>
                <div class="left"> 
                    <label>Thứ tự vị trí:</label><br />
                    <asp:TextBox ID="txtLocationA" runat="server" style="width:300px"></asp:TextBox>
                </div>
            </div><br class="clear"/><br />
			<p>
                <asp:Button ID="btnCreate" Text="Tạo mới" runat="server" 
                    onclick="btnCreate_Click" OnClientClick="return validate_Create()"/>
                <asp:Button ID="btnCancelA" Text="Tạo lại" runat="server" 
                    onclick="btnCancelA_Click"/>
			</p>
		</div>
	

    <script type="text/javascript">
        function validate_Create() {
            var txtMenuNameA_vi = document.getElementById("<%=txtMenuNameA_vi.ClientID%>").value;
            if (txtMenuNameA_vi == null || txtMenuNameA_vi == "") {
                alert("Tên danh mục tiếng việt không để trống!");
                document.getElementById("<%=txtMenuNameA_vi.ClientID%>").focus();
                return false;
            }
            var txtMenuNameA_en = document.getElementById("<%=txtMenuNameA_en.ClientID%>").value;
            if (txtMenuNameA_en == null || txtMenuNameA_en == "") {
                alert("Tên danh mục tiếng anh không để trống!");
                document.getElementById("<%=txtMenuNameA_en.ClientID%>").focus();
                return false;
            }
            var txtURLA = document.getElementById("<%=txtURLA.ClientID%>").value;
            if (txtURLA == null || txtURLA == "") {
                alert("Đường dẫn không để trống!");
                document.getElementById("<%=txtURLA.ClientID%>").focus();
                return false;
            }
            var txtLocationA = document.getElementById("<%=txtLocationA.ClientID%>").value;
            if (txtLocationA == null || txtLocationA == "") {
                alert("Thứ tự vị trí không để trống!");
                document.getElementById("<%=txtLocationA.ClientID%>").focus();
                return false;
            }
            if (!txtLocationA.match("[0-9]*$")) {
                alert("Thứ tự vị trí chỉ được nhập số!");
                document.getElementById("<%=txtLocationA.ClientID%>").focus();
                return false;
            }
            return true;
        }

    </script>
    </div>
<!-- End Create -->
<!-- Begin Edit -->
	<div id="edit" class="onecolumn" runat="server" visible="false">
		<div class="header">
			<span>Chỉnh Sửa Danh Mục</span>
			<div class="switch" style="margin:7px 15px;">
				<table cellpadding="0" cellspacing="0">
				<tbody>
					<tr>
						<td>
                            <a href="MenuList.aspx?Action=Create" class="button">Thêm mới</a>
						</td>
                        <td>
                            <a href="MenuList.aspx" class="button">Danh sách</a>
						</td>
					</tr>
				</tbody>
				</table>
			</div>
		</div>
		<br class="clear"/>
		<div class="content">
            <asp:Label ID="lblWarningE" runat="server"></asp:Label>
            <fieldset class="fieldset"><legend><label>Tên danh mục</label></legend>
			    <div class="left">
                    Tiếng Việt:<br />
                    <asp:TextBox ID="txtMenuNameE_vi" runat="server" style="width:300px"></asp:TextBox>
			    </div>
                <div class="left">
                    Tiếng Anh:<br />
                    <asp:TextBox ID="txtMenuNameE_en" runat="server" style="width:300px"></asp:TextBox>
                </div>
            </fieldset><br class="clear"/>
            <div style="padding-left:12px;">
                <div class="left"> 
                    <label>Loại danh mục:</label><br />
                    <asp:DropDownList ID="ddlMenuBack_FrontEndE" runat="server" style="width:311px" AutoPostBack="True" 
                        onselectedindexchanged="ddlMenuBack_FrontEndE_SelectedIndexChanged"></asp:DropDownList>
                </div>
                <div class="left">
                    <label>Thuộc danh mục:</label><br />
                    <asp:DropDownList ID="ddlMenuNameE" runat="server" style="width:311px"></asp:DropDownList> 
                </div>
            </div><br class="clear"/><br />
            <div style="padding-left:12px;">
                <div class="left"> 
                    <label>Đường dẫn:</label><br />
                    <asp:TextBox ID="txtURLE" runat="server" style="width:300px"></asp:TextBox>
                </div>
                <div class="left"> 
                    <label>Thứ tự vị trí:</label><br />
                    <asp:TextBox ID="txtLocationE" runat="server" style="width:300px"></asp:TextBox>
                </div>
            </div><br class="clear"/><br />
			<p>
                <asp:Button ID="btnEdit" Text="Cập nhật" runat="server" onclick="btnEdit_Click" OnClientClick="return validate_Edit()"/>
                <asp:Button ID="btnCancelE" Text="Làm lại" runat="server" 
                    onclick="btnCancelE_Click"/>
			</p>
		</div>
	
    <script type="text/javascript">
        function validate_Edit() {
            var txtMenuNameE_vi = document.getElementById("<%=txtMenuNameE_vi.ClientID%>").value;
            if (txtMenuNameE_vi == null || txtMenuNameE_vi == "") {
                alert("Tên danh mục tiếng việt không để trống!");
                document.getElementById("<%=txtMenuNameE_vi.ClientID%>").focus();
                return false;
            }
            var txtMenuNameE_en = document.getElementById("<%=txtMenuNameE_en.ClientID%>").value;
            if (txtMenuNameE_en == null || txtMenuNameE_en == "") {
                alert("Tên danh mục tiếng anh không để trống!");
                document.getElementById("<%=txtMenuNameE_en.ClientID%>").focus();
                return false;
            }
            var txtURLE = document.getElementById("<%=txtURLE.ClientID%>").value;
            if (txtURLE == null || txtURLE == "") {
                alert("Đường dẫn không để trống!");
                document.getElementById("<%=txtURLE.ClientID%>").focus();
                return false;
            }
            var txtLocationE = document.getElementById("<%=txtLocationE.ClientID%>").value;
            if (txtLocationE == null || txtLocationE == "") {
                alert("Thứ tự vị trí không để trống!");
                document.getElementById("<%=txtLocationE.ClientID%>").focus();
                return false;
            }
            if (!txtLocationE.match("[0-9]*$")) {
                alert("Thứ tự vị trí chỉ được nhập số!");
                document.getElementById("<%=txtLocationE.ClientID%>").focus();
                return false;
            }
            return true;
        }

    </script>
    </div>
<!-- End Edit -->
</asp:Content>
